﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace DownloadTool.Util
{
    /// <summary>
    /// 用于对文件夹进行操作
    /// </summary>
    class Folder
    {
        /// <summary>
        /// 创建文件夹
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public static  bool create(string path)
        {
            if (check(path))
            {
                return true;
            }
            if (Directory.CreateDirectory(path) != null)
            {
                return true;
            }
            return false;
        }
        /// <summary>
        /// 检查文件夹
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public static bool check(string path)
        {
            return Directory.Exists(path);
        }

        /// <summary>
        /// 删除文件夹
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public static bool del(string path)
        {
            Directory.Delete(path, true);
            return check(path);
        }

        /// <summary>
        /// 打开文件夹
        /// </summary>
        /// <param name="path"></param>
        public static void open(String path){
            System.Diagnostics.Process.Start("explorer.exe", path);
        }
    }
}

